package com.etc.jdk8;

import java.util.Comparator;
import java.util.Map;

public class TestLambda {
    public static void main(String[] args) {

        //传统
        TestIA.test1(new IA() {
            @Override
            public void print() {
                System.out.println("匿名内部类");
            }
        });


        //lambda写法
        TestIA.test1(() -> {
            System.out.println("拉姆达表达式");
        });

        Runnable r = () -> {
            System.out.println("runnable");
        };


        //其他应用 遍历集合map
        Map map = Map.of(1, "A", 2, "B");

        //lambda
        map.forEach((k, v) -> {
            System.out.println(k + "," + v);
        });


    }
}


class TestIA {
    public static void test1(IA ia) {
        ia.print();
    }
}

@FunctionalInterface
interface IA {
    //抽象方法
    void print();

}
